<?php
/**
 *       _____
 *      /  \  \      _       _    _____________   ___     ___ '  TM
 *     / /\ \  \    | |\    | |\ /_____   _____\ | - |   | - |
 *    / /  \ \  \   | | |   | | ||____/| |\____| | - |___| - |
 *   / /   /\ \  \  | | |   | | |    | | | |     | -  ___  - |
 *  / /   /  \ \  \ | |_|___| | |    | |_| |     | - |   | - |
 * / /___/    \ \__\|________ |/     |/___\|     |___|   |___|
 *________________________________________________________________________

 * Filters for In/Out Put
 *
 * PHP version 5
 *
 * LICENSE: GNU General Public License v3
 *
 * @package    Security
 * @author     Charly Poly <CharlyPoly@gmail.com>
 * @copyright  2009 Authentic Development Group
 * @license    GNU General Public License v3
 * @since      File available since Release 0.1.0
 */

class filters {

    static function Mail(&$str) {
        escapeshellarg($str);
        escapeshellcmd($str);
        $str = str_replace('\r','\\r',$str);
        $str = str_replace('\t','\\t',$str);
    }

    static function Php(&$str) {
        $PHP = array("\\0"=>"\\0", "\\a"=>"\\a", "\\b"=>"\b", "\\n"=>"\\n",  "\\r"=>"\\r", "\\t"=>"\\t", "\\v"=>"\\v", "'"=>"\'", "\""=>"\\\"");

        foreach ($PHP as $search=>$replace) {
            $str = str_replace($search,$replace, $str);
        }
        $str = addslashes($str);
	}

    static function Xss(&$str) {
        $XSS = array('EMBED'=>'',
                     'script'=>'s\cript',
                     'VBS'=>'',
                     'location'=>'',
                     'cookie'=>'',
                     'LINK'=>'l\ink',
                     'IFRAME'=>'i\frame',
                     'javascript'=>'ja\vascript',
                     'refresh'=>'',
                     'OBJECT'=>'',
                     'onload'=>'',
                     'onStart'=>'',
                     'document'=>'',
                     '#'=>'\#',
                     '$'=>'\$',
                     '*'=>'\*',
                     '='=>'\=',
                     '+'=>'\+',
                     ':'=>'\:',
                     '&'=>'\&',
                     '['=>'\]',
                     ']'=>'\[',
                     );
        foreach ($XSS as $search=>$replace) {
            $str = str_replace($search, $replace, $str);
        }
        $str = strip_tags($str);
        $str = htmlentities($str);
        $str = addslashes($str);
    }
}
?>
